<template>
	<div class="easyd-weixin-Box ">
		<div class="app_page_box" style="bottom:50px;">
			<div class="app_page">

				<div class="app_list_box">
					<div class="app_box_content">
						<div class="app_box_content_left">
							原密码
						</div>
						<div class="app_box_content_right">
							<input class="T1 C4" type="password" v-model="passwordData.password" name="" id="" placeholder="请输入原密码" value="" />
						</div>
					</div>
				</div>
				<div class="app_list_box">
					<div class="app_box_content">
						<div class="app_box_content_left">
							新密码
						</div>
						<div class="app_box_content_right">
							<input class="T1 C4" type="password" v-model="passwordData.newPassword" name="" id="" placeholder="请输入新密码" value="" />
						</div>
					</div>
				</div>
				<div class="app_list_box">
					<div class="app_box_content">
						<div class="app_box_content_left">
							确认密码
						</div>
						<div class="app_box_content_right">
							<input class="T1 C4" type="password" v-model="passwordData.rePassword" name="" id="" placeholder="请确认密码" value="" />
						</div>
					</div>
				</div>

			</div>
		</div>
		<div class="app_bottom_box">
			<div class="app_bottom_box_right" @click="updatePassword()">确认保存</div>
		</div>

	</div>
</template>

<script>
	import { mapState, mapMutations } from "vuex";
	export default {

		data() {
			return {

			};
		},
		computed: {
			...mapState({
			    passwordData    : state => state.UserModule.passwordData
			})
		},
		mounted() {

		},
		methods: {

			//  ...mapMutations(["ShopIndexModule/updateIsShopGuide"]),

			updatePassword(e) {
	            if(this.$common.vEmpty(this.passwordData.password)){
	                this.$easyUtil.errorToast(this,'密码不能为空');  
	                return; 
	            }
	            if(this.$common.vEmpty(this.passwordData.newPassword)){
	                this.$easyUtil.errorToast(this,'新密码不能为空');  
	                return; 
	            }
	            if(this.passwordData.newPassword != this.passwordData.rePassword){
	                this.$easyUtil.errorToast(this,'两次密码输入不一致');  
	                return; 
	            }
				
				var params = {
		            u_id : this.$userData.getUID(),
		            oldPassword : this.passwordData.password,
		            newPassword : this.passwordData.newPassword,
				};

				this.$easyUtil.startLoading(this);
				this.$http.postHttp(
					this.$API.apiUpdatePassword,
					params,
					rs => {
						console.log(rs);
		                this.$easyUtil.endLoading(this)
		                this.$easyUtil.successToast(this, '密码修改成功');
		                this.$store.commit("UserModule/clearPasswordData");
		                history.go(-1);
					}
				);
			},
		}
	};
</script>

<style lang="stylus" scoped>
	@import '~PUBLIC_CSS';
</style>